package com.lz.yz.order.service.impl;

import com.lz.yz.core.AbstractService;
import com.lz.yz.order.dao.TurnoversMapper;
import com.lz.yz.order.entity.Turnovers;
import com.lz.yz.order.enumeration.TurnoversType;
import com.lz.yz.order.service.TurnoversService;
import com.lz.yz.outing.service.CreateNo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;


/**
 * Created by CodeGenerator on 2017/11/10.
 */
@Service
@Transactional
public class TurnoversServiceImpl extends AbstractService<Turnovers> implements TurnoversService {

    @Autowired
    CreateNo createNo;

    @Autowired
    TurnoversMapper turnoversMapper;


    @Override
    public Integer insert(Integer accountId, TurnoversType turnoverType, Integer ValueType, BigDecimal totalPrice, String orderNo) {
        Turnovers turnover=new Turnovers();
        turnover.setTurnoverNo(createNo.getNo(accountId, turnoverType.getStr()));
        turnover.setAccountId(accountId);
        turnover.setTurnoverType(turnoverType.getTypeValue());
        turnover.setDesc(turnoverType.getType());
        turnover.setValueType(ValueType);
        turnover.setValue(totalPrice);
        turnover.setOrderNo(orderNo);
        return turnoversMapper.insertSelective(turnover);
    }

}
